package com.casic.modules.sys.controller;

import java.util.Map;
import com.casic.common.utils.R;
import com.casic.common.base.entity.PageEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.casic.modules.sys.entity.SysDictEntity;
import com.casic.modules.sys.service.SysDictService;


/**
 * 数据字典表
 * 
 * @author mfc
 * @email 123456789@qq.com
 * @date 2019-05-06 15:22:42
 */
@RestController
@RequestMapping("sysdict")
public class SysDictController {
	@Autowired
	private SysDictService sysDictService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("sysdict:list")
	public R list(@RequestParam Map<String, Object> params){
        PageEntity<SysDictEntity> page=sysDictService.findPage(params);
		return R.ok().put("page", page);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("sysdict:info")
	public R info(@PathVariable("id") String id){
		SysDictEntity sysDict = sysDictService.findById(id);
		return R.ok().put("sysDict", sysDict);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("sysdict:save")
	public R save(@RequestBody SysDictEntity sysDict){
		sysDictService.save(sysDict);
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("sysdict:update")
	public R update(@RequestBody SysDictEntity sysDict){
		sysDictService.edit(sysDict);
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("sysdict:delete")
	public R delete(@RequestBody String[] ids){
		sysDictService.removeByIds(ids);
		return R.ok();
	}
	
}
